package edu.ncsu.csc.camera;

// for SPOT
import com.sun.squawk.util.StringTokenizer;
// for PC
//import java.util.StringTokenizer;

public class SPacket
{
	public int[] means;
	public int[] deviations;
	
	public SPacket(int[] means, int[] deviations)
	{
		this.means = means;
		this.deviations = deviations;
	}
	
	public static SPacket build(String str)
	{
		StringTokenizer st = new StringTokenizer(str, " \r");
		int tokens = st.countTokens();
		if(tokens == 7)	// S rmean gmean bmean rdev gdev bdev
		{
			if(st.nextToken().equals("S"))
			{
				int[] _means = new int[3];
				_means[0] = Integer.parseInt(st.nextToken());
				_means[1] = Integer.parseInt(st.nextToken());
				_means[2] = Integer.parseInt(st.nextToken());
				
				int[] _deviations = new int[3];
				_deviations[0] = Integer.parseInt(st.nextToken());
				_deviations[1] = Integer.parseInt(st.nextToken());
				_deviations[2] = Integer.parseInt(st.nextToken());
				
				return new SPacket(_means, _deviations);
			}
		}
		return null;
	}

	public String toString()
	{
		String result = "S ";
		for(int k = 0; k < 3; k++)
			result += means[k] + " ";
		for(int k = 0; k < 3; k++)
			result += deviations[k] + " ";
		return result;
	}
	
}